//
//  main.c
//  UM
//
//  Created by Simon Yang on 2021/11/23.
//

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define FILE_NAME “User_Pwd.txt”
#define SIZE 128

int manageer_pwd = 123;

void manager_login_UI(void) {
    // MacOS
    system("Clear");
    // Windows
    // system("cls");
    printf("\n");
    printf("\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n\n");
    printf("\t\t1. Login Manager!\n");
    printf("\t\t2. Exit!\n\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n");
    printf("\n");
    printf("\n");
}



void manager_input_pwd_UI(void) {
    // MacOS
    system("Clear");
    // Windows
    // system("cls");
    printf("\n");
    printf("\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n\n");
    printf("\t\t1. Login Admin Account!\n");
    printf("\t\t2. Forget Your Password!!\n");
    printf("\t\t3. Exit!\n\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n");
    printf("\n");
    printf("\n");
}

void manager_EXE_UI(void) {
    // MacOS
    system("Clear");
    // Windows
    // system("cls");
    printf("\n");
    printf("\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n\n");
    printf("\t\t1. Add Client Into Database!\n");
    printf("\t\t2. Delete a Client From Database!\n");
    printf("\t\t3. Delete All Client From Database!\n");
    printf("\t\t4. Exit!\n\n");
    printf("\t==============================================\t\n");
    printf("\t==============================================\t\n");
    printf("\n");
    printf("\n");
}

int check_pwd(int usr_input_pwd) {
    // check Admin password
    if (usr_input_pwd == manageer_pwd) {
        // pwd correct
        return 0;
    } else {
        // pwd error
        return 1;
    }
    
}

void manager_EXE_UI_exe(void) {
    int usr_EXE_choice;

    // Add / Delete / Delete All
    manager_EXE_UI();
    printf("\tPlease input your choice: ");
    scanf("%d", &usr_EXE_choice);

    // EXE choice
    switch (usr_EXE_choice){
        case 1:
            // 1. Add Client Into Database!
            printf("Add Finished!\n");
            break;
        case 2:
            // 2. Delete a Client From Database!
            printf("Delete Finished!\n");
        case 3:
            // 3. Delete All Client From Database!
            printf("Delete All Finished!\n");
        case 4:
            // 4. Exist!
            printf("Exist!\n");

        default:
            break;

    }




}

void manager_input_pwd_UI_exe(void) {
    int user_account_choice;
    int usr_input_pwd;
    int check_pwd_result;
    
    // choose login directly or change password
    manager_input_pwd_UI();
    printf("\tPlease input your choice: ");
    scanf("%d", &user_account_choice);
    
    // Account State
    switch (user_account_choice) {
        case 1:
            printf("Please input Admin password: ");
            scanf("%d", &usr_input_pwd);
            
            while(1) {
                // check input password
                check_pwd_result = check_pwd(usr_input_pwd);

                if (check_pwd_result == 1)
                {
                    /* input pwd error */
                    printf("Please input Admin password again: ");
                    scanf("%d", &usr_input_pwd);
                } else {
                    // input pwd correct
                    break;
                }
            }
            
            // manager_EXE_UI_exe
            manager_EXE_UI_exe();
            
            break;
        // case 2:

            
        default:
            break;
    }
}

void manager_login_UI_exe(void) {
    int user_login_choice;
    
    // manager login
    manager_login_UI();
    printf("\tPlease input your choice: ");
    scanf("%d", &user_login_choice);
    
    // Login State
    switch (user_login_choice) {
        case 1:
            // Clear Screen
            manager_input_pwd_UI_exe();
            break;
            
        case 2:
            printf("Exit!!\n");
            break;
            
        default:
            break;
    }
}

void manager(void) {
    manager_login_UI_exe();
    
}

int main(int argc, const char * argv[]) {
    // insert code here...
    manager();
    return 0;
}
